package com.RMP
{
    import flash.display.*;
    import flash.events.*;

    public class TriColShell extends Sprite
    {
        var startIndexChar:String;
        var myXMLList:XMLList;
        var counter:int;
        var shortTextArray:Array;
        var fadeSpeed:Number;
        var myRoot:MovieClip;
        var shortText:TwoLineText;
        var startIndexNum:int;

        public function TriColShell(param1:MovieClip, param2:Number, param3:XMLList, param4) : void
        {
            trace("myXMList " + param3);
            myRoot = param1;
            fadeSpeed = param2;
            myXMLList = param3;
            startIndexChar = param4;
            startIndexNum = param4 * 105;
            buildList();
            myRoot.stage.addEventListener(Event.RESIZE, onResizer);
            doResize();
            return;
        }

        function doResize() : void
        {
            var _loc_1:int = 0;
            _loc_1 = startIndexNum;
            while (_loc_1 < shortTextArray.length)
            {
                
                if (shortTextArray[_loc_1] != undefined)
                {
                    var _loc_2:* = myRoot.unitW / 75;
                    shortTextArray[_loc_1].scaleY = myRoot.unitW / 75;
                    shortTextArray[_loc_1].scaleX = _loc_2;
                    if (_loc_1 - startIndexNum <= 34)
                    {
                        shortTextArray[_loc_1].x = 0;
                        shortTextArray[_loc_1].y = Math.round((_loc_1 - startIndexNum) * 14 * myRoot.unitW / 75);
                    }
                    else if (_loc_1 - startIndexNum <= 69)
                    {
                        shortTextArray[_loc_1].x = Math.round(4 * (myRoot.unitW + myRoot.gutterW));
                        shortTextArray[_loc_1].y = Math.round((_loc_1 - 35 - startIndexNum) * 14 * myRoot.unitW / 75);
                    }
                    else
                    {
                        shortTextArray[_loc_1].x = Math.round(8 * (myRoot.unitW + myRoot.gutterW));
                        shortTextArray[_loc_1].y = Math.round((_loc_1 - 70 - startIndexNum) * 14 * myRoot.unitW / 75);
                    }
                }
                _loc_1++;
            }
            return;
        }

        function buildList() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            counter = 0;
            shortTextArray = new Array();
            _loc_1 = 0;
            while (_loc_1 < myXMLList.length())
            {
                
                if (myXMLList[_loc_1].item.length() > 0)
                {
                    if (counter > startIndexNum + 32 && counter < startIndexNum + 38)
                    {
                        counter = startIndexNum + 35;
                    }
                    if (counter >= startIndexNum)
                    {
                        shortTextArray[counter] = new ShortTextBold(myRoot, myXMLList[_loc_1].@label, counter);
                        shortTextArray[counter].name = "shortText" + counter;
                        addChild(shortTextArray[counter]);
                    }
                    var _loc_4:* = counter + 1;
                    counter = _loc_4;
                    if (counter >= startIndexNum + 105)
                    {
                        break;
                    }
                    _loc_2 = 0;
                    while (_loc_2 < myXMLList[_loc_1].item.length())
                    {
                        
                        if (counter == 70)
                        {
                        }
                        if (counter >= startIndexNum)
                        {
                            shortTextArray[counter] = new TwoLineText(myRoot, myXMLList[_loc_1].item[_loc_2].@label, myXMLList[_loc_1].item[_loc_2].season, counter);
                            shortTextArray[counter].dbId = myXMLList[_loc_1].item[_loc_2].@id;
                            shortTextArray[counter].name = "shortText" + counter;
                            shortTextArray[counter].addEventListener(MouseEvent.MOUSE_OVER, btnRollOver, false, 0, true);
                            shortTextArray[counter].addEventListener(MouseEvent.MOUSE_OUT, btnRollOut, false, 0, true);
                            shortTextArray[counter].addEventListener(MouseEvent.CLICK, btnClick, false, 0, true);
                            addChild(shortTextArray[counter]);
                        }
                        var _loc_4:* = counter + 1;
                        counter = _loc_4;
                        var _loc_4:* = counter + 1;
                        counter = _loc_4;
                        if (_loc_2 < (myXMLList[_loc_1].item.length() - 1))
                        {
                            if (counter != startIndexNum + 35 && counter != startIndexNum + 70)
                            {
                                var _loc_4:* = counter + 1;
                                counter = _loc_4;
                            }
                        }
                        if (counter >= startIndexNum + 105)
                        {
                            break;
                        }
                        _loc_2++;
                    }
                    if (counter >= startIndexNum + 105)
                    {
                        break;
                    }
                    if (counter != startIndexNum + 35 && counter != startIndexNum + 70)
                    {
                        var _loc_4:* = counter + 1;
                        counter = _loc_4;
                    }
                    if (counter >= startIndexNum + 105)
                    {
                        break;
                    }
                }
                _loc_1++;
            }
            return;
        }

        function onResizer(event:Event)
        {
            doResize();
            return;
        }

        function btnRollOver(event:MouseEvent) : void
        {
            event.currentTarget.rollOverEvent();
            return;
        }

        function btnRollOut(event:MouseEvent) : void
        {
            event.currentTarget.rollOutEvent();
            return;
        }

        function btnClick(event:MouseEvent) : void
        {
            updateAddress(event.currentTarget.dbId);
            return;
        }

        function updateAddress(param1) : void
        {
            switch(myRoot.pathNames[1])
            {
                case "awards":
                {
                    myRoot.clickPathNames = ["practice", "awards", myRoot.pathNames[2], param1, 0];
                    myRoot.updateAddress("/" + "practice" + "/" + "awards" + "/" + myRoot.pathNames[2] + "/" + param1 + "/" + 0 + "/");
                    break;
                }
                case "press":
                {
                    switch(myRoot.pathNames[2])
                    {
                        case "publications":
                        {
                            myRoot.clickPathNames = ["practice", "press", "publications", "archive", myRoot.pathNames[4], param1, 0];
                            myRoot.updateAddress("/" + "practice" + "/" + "press" + "/" + "publications" + "/" + "archive" + "/" + myRoot.pathNames[4] + "/" + param1 + "/" + 0 + "/");
                            break;
                        }
                        case "releases":
                        {
                            myRoot.clickPathNames = ["practice", "press", "releases", "archive", myRoot.pathNames[4], param1, 0];
                            myRoot.updateAddress("/" + "practice" + "/" + "press" + "/" + "releases" + "/" + "archive" + "/" + myRoot.pathNames[4] + "/" + param1 + "/" + 0 + "/");
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                case "lectures":
                {
                    myRoot.clickPathNames = ["practice", "lectures", myRoot.pathNames[2], param1, 0];
                    myRoot.updateAddress("/" + "practice" + "/" + "lectures" + "/" + myRoot.pathNames[2] + "/" + param1 + "/" + 0 + "/");
                    break;
                }
                case "selected-text":
                {
                    myRoot.clickPathNames = ["practice", "selected-text", myRoot.pathNames[2], param1, 0];
                    myRoot.updateAddress("/" + "practice" + "/" + "selected-text" + "/" + myRoot.pathNames[2] + "/" + param1 + "/" + 0 + "/");
                    break;
                }
                case "books":
                {
                    myRoot.clickPathNames = ["practice", "books", "archive", myRoot.pathNames[3], param1, 0];
                    myRoot.updateAddress("/" + "practice" + "/" + "books" + "/" + "archive" + "/" + myRoot.pathNames[3] + "/" + param1 + "/" + 0 + "/");
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }

    }
}
